<template>
    <div class="messagePer" >
        <div class="mesBox" :class="[{ fullScreen: isFullscreen }]">
            <div class="mesMenu">
                <div class="mesMenuBtn" @click="changeFullscreen">
                    <el-icon size="16"><FullScreen /></el-icon>
                </div>
                <div class="mesMenuBtn" @click="closeDetailMudle" >
                    <el-icon size="16"><Close /></el-icon>
                </div>
            </div>
            <div class="mesCon" :class="{ slideOpen: isClickMeid }">
                <!-- left -->
				<!-- :class="[{ width50: isClickMeid }]" -->
                <div class="mesCLe" >
                    <div class="mesHeader">
                        <div class="mesTit">
                            消息中心
                        </div>
                    </div>
                    <div class="mesCLeB"  v-loading="loading">
                        <ul class="mesCUl">
                            <li class="mesCLi" :class="[{act:isClickMeid.id ==item.id }]" v-for="(item,index) in messageListStore.permessageList" :key="item.id" @click="clickIndex(item)">
                                <div class="mesLsL">
                                    <div class="mesLsLT">
                                        <span class="meSp">{{ item.title }}</span>
                                        <i class="meSpi" v-if="item.messagecount > 0">{{ item.messagecount}}</i>
                                    </div>
                                </div>
                                <div class="mesLsR" >
                                    <div class="mesIc">
                                        <div class="mesBj ybj" v-if="item.allmessagecount > 0">已报价</div>
                                        <div class="mesBj wbj" v-else>未报价</div>
                                    
                                    </div>
                                    <div class="mesTime" v-if="!isClickMeid">
                                       {{ formatTimeDifference(messageListStore.downTime,item.addtime) }}
                                    </div>
                                </div>
                            </li>
                        </ul>
                        <div class="noMore" v-if="!loading">
                            <p class="noMoreP">没有内容了</p>
                        </div>
                    </div>
                    <div class="zuhua" @click="closeModule"></div>
                </div>
                <!-- right -->
                <div class="mesCri" v-if="isClickMeid" :class="[{ width50: isClickMeid }]">
                    <div class="mesCLB" v-loading="loading2">
                        <div class="mesHeader"></div>
                        <div class="mlbUlB">
                            <ul class="mlbUl">
                                <li class="mlbLi "
                                    :class="[{isdu:item.status==5,act:messageListStore.childAct?.id == item.id}]"
                                    @click="showDetail(item)" 
                                    v-for="(item,index) in messageListStore.projectmessagelist" 
                                    :key="item.id" >
                                    <p class="mname">{{item.companyname}}</p>
                                    <p class="mtime"> {{formatTimeDifference(messageListStore.downTime,item.offertime) }}</p>
                                </li>
                            </ul>
                            <div class="noMore noHei" v-if="messageListStore.projectmessagelist.length <=0">
                                <div class="noImg"> </div>
                                <p class="noMoreP">暂无企业报价</p>
                            </div>
                        </div>
                    </div>
                    <div class="mesCRB" v-if="messageListStore.childAct">
                        <div class="mesHeader"></div>
                        <div class="mesCRBC">
                            <div class="hqbj">
                                获取报价详情
                            </div>
                            <div class="mesPre">
                                <img class="mesPreImg" src="@/assets/miscel/mes1.jpg?v=100" alt="">
                            </div>
                            <div class="mesPreBtns">
                                <div class="mesPreBtn" @click="showDetailDe()">点击查看详情</div>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

	<el-drawer   v-model="drawerShow" direction="btt" size="80%" append-to-body="true" show-close="true"  :with-header="false">
		<div class="mesCon" style="height: auto;">
			<div class="mesMenu1">
				<div class="mesMenuBtn1" @click="drawerShow =false" >
				    <el-icon size="16"><Close /></el-icon>
				</div>
			</div>
			
			<div class="mesCri" style="display: flex!important;width: 100%;">
			<div class="mesCLB" style="padding: 0;" v-loading="loading2">
			    <div class="mesHeader">
					<div class="mesTit" style="text-align: center;width: 100%;">
						来自企业报价
					</div>
				</div>
			    <div class="mlbUlB">
			        <ul class="mlbUl">
			            <li class="mlbLi "
			                :class="[{isdu:item.status==5,act:messageListStore.childAct?.id == item.id}]"
			                @click="showDetailDe(item)" 
			                v-for="(item,index) in messageListStore.projectmessagelist" 
			                :key="item.id" >
			                <p class="mname">{{item.companyname}}</p>
			                <p class="mtime"> {{formatTimeDifference(messageListStore.downTime,item.offertime) }}</p>
			            </li>
			        </ul>
			        <div class="noMore noHei" style="padding: 100px 0 0;" v-if="messageListStore.projectmessagelist.length <=0 && loading2 ==false">
			            <div class="noImg"> </div>
			            <p class="noMoreP">暂无企业报价</p>
			        </div>
			    </div>
			</div>
			</div>
		</div>
		
	</el-drawer>

    <messagePersonalAdd v-if="isShowDetail" :parent="isClickMeid"  @onCloseModule="onCloseModule"></messagePersonalAdd>
</template>

<script setup lang='ts'>
const imgurl = import.meta.env.VITE_APP_TITLE + '/assets/images/';
import { useUserStore } from "@/store/modules/user";
import { useSystemStore } from "@/store/modules/system";
import { useMessageListStore } from "@/store/modules/messagelist";

import { ArrowDown,Close,FullScreen } from '@element-plus/icons-vue'
import pdfapi from "@/api/pdf.ts"
import {formatTimeDifference,timestampToDatetime,ispdfRE} from "@/utils/timeFun"

import messagePersonalAdd from "./messagePersonalAdd.vue";



const drawerShow =ref<any>(false);
const api = inject('$base', null as any);
const baseurl = inject('$baseurl', null as any);
const useStore = useUserStore();
const base = useSystemStore();
const messageListStore = useMessageListStore();
const isFullscreen = ref(false);
const isClickMeid = ref<any>(""); //一级路由选中页面
const loading = ref<any>(false)
const loading2 = ref<any>(false)
const isShowDetail = ref<any>(false); //是否显示详情页面
const page = ref(1);


window.addEventListener('resize', function(){
	const width = window.innerWidth;
	if(width < 768){
		if(isClickMeid.value && !isShowDetail.value)
		{		
			drawerShow.value =true
		}
	}else{
		drawerShow.value= false;
	}
});

function projectlist(){
	loading.value = true
    const data= {
        userid:useStore.userIds,
        page:page.value
    }
    pdfapi.projectlist(data).then((res)=>{
		loading.value = false
        console.log(res);
        messageListStore.downTime = res.data.time
        messageListStore.permessageList = res.data.projectlist
    })
}
/**
 * 点击进入详情单页面
 */
 function clickIndex(item) {
    var  id = item.id;
    isClickMeid.value = item;
    messageListStore.childAct = "";
	loading2.value = true;
	
	
	if(base.isMobile)
	{
		drawerShow.value =true
	}
    const data= {
        userid:useStore.userIds,
        page:1,
        projectid:id,
        status:0
    }
    pdfapi.projectmessagelist(data).then((res)=>{
		loading2.value = false;
        messageListStore.projectmessagelist = res.data.projectmessagelist;
        messageListStore.downTime = res.data.time;
    })
}

/**
 * 查看报价单详情页面
 */
 function showDetail(item) {
    messageListStore.childAct = item;
}
/**
 * 查看详情 =屏幕放大
 */

function showDetailDe(item?:any){
	if(item)
	{
		drawerShow.value =false;
		isShowDetail.value = true;
		messageListStore.childAct = item;
	}
	else
	{
		isShowDetail.value = true;
	}
    
}
/**
 * 关闭详情弹出层
 */
 function onCloseModule(){
    isShowDetail.value = false;
}

function closeModule(){
    isClickMeid.value = ""
}

/**
 * 关闭消息中心
 */
function closeDetailMudle(){
    base.isMessageType = 0;
}
/**
 * 全屏放大
 */
function changeFullscreen() {
    isFullscreen.value = !isFullscreen.value
}

onMounted(() => {
   
    projectlist();




})

</script>



<style lang="scss" scoped>
.messagePer {
    width: 100%;
    height: 100%;
    display: block;
    position: fixed;
    top: 0;
    left: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    display: flex;
    justify-content: center;
    align-items: center;
}

.mesBox {
    width: 90%;
    max-width: 1100px;
    height: 80%;
    background: #ffffff;

    box-sizing: border-box;
    border-radius: 10px;
    transition: 0.2s ease;
    flex-direction: column;
    display: flex;
    position: relative;
    .mesMenu{
        display: flex;
        justify-content: flex-start;
        align-items: center;

        position: absolute;
        top: 16px;
        right: 24px;
        z-index:10;
        .mesMenuBtn{
            width: 26px;
            height: 26px;
            display: flex;
            justify-content: center;
            align-items: center;
            align-content: center;   
            margin-right: 2px;
            cursor: pointer;
            &:last-child{
                margin-right: 0;
            }
            &:hover{
                color: #2379f7
            }
        }
    }
    
}

.fullScreen {
    width: 100%;
    max-width: 100%;
    height: 100%;
    border-radius: 0;
}



.mesHeader {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 45px;
    line-height: 45px;
    padding: 0 20px;
    box-sizing: border-box;

    .mesTit {
        font-size: 18px;
        color: #2379f7;
        font-family: "siyuanM";
    }
}


.mesCon {
    display: flex;
    justify-content: space-between;
    flex: 1;
    height: 0;
    background: #ffffff;
    border-radius: 6px;
    overflow: hidden;

    .mesCLe {
		width: 0;
		flex: 1;
        width: 100%;
        height: 100%;
        transition: 0.3s linear;
        padding: 20px 4px 30px;
        box-sizing: border-box;
        display: flex;
        flex-wrap: nowrap;
        flex-direction: column;
        position: relative;

      

        .mesCLeB {
            flex: 1;
            width: 100%;
            overflow: auto;
            padding: 0 20px;

            .mesCUl {
                width: 100%;

                .mesCLi {
                    display: flex;
                    justify-content: space-between;
                    align-items: center;
                    align-content: center;
                    line-height: 24px;
                    padding: 10px 0;
                    border-bottom: 1px solid #dbe2ee;
                    cursor: pointer;

                    .mesLsL {
                        display: flex;
                        justify-content: flex-start;
                        flex: 1;
                        width: 0;

                        .mesLsLT {
                            width: 100%;
                            font-family: 'siyuanR';

                            box-sizing: border-box;
                            font-weight: normal;
                            position: relative;
                            display: flex;
                            justify-content: flex-start;
                            align-items: center;
                            align-content: center;

                            .meSp {
                                font-size: 15px;
                                color: #010101;
                                display: block;
                                white-space: nowrap;
                                text-overflow: ellipsis;
                                overflow: auto;
                                padding-left: 6px;

                                &::after {
                                    content: '';
                                    width: 2px;
                                    height: 14px;
                                    background: #010101;
                                    position: absolute;
                                    left: 0;
                                    top: 50%;
                                    transform: translate(0, -50%)
                                }

                            }

                            .meSpi {
                                margin-left: 8px;
                                min-width: 16px;
                                height: 16px;
                                line-height: 16px;
                                text-align: center;
                                background: #fb6e76;
                                font-size: 12px;
                                color: #ffffff;
                                border-radius: 15px;
                                padding: 0 5px;
                                display: inline-block;
                                font-style: normal;
                            }
                        }
                    }

                    .mesLsR {
                        display: flex;
                        justify-content: space-between;
                        align-items: center;
                        align-content: center;
                        margin-left: 20px;

                        .mesIc {
                            margin-right: 10px;

                            .mesBj {
                                padding: 0 10px;
                                height: 22px;
                                line-height: 22px;
                                font-size: 12px;
                                font-family: 'siyuanR';
                                border-radius: 10px;

                                &.ybj {
                                    background: #e8f1fe;
                                    color: #2379f7;
                                }

                                &.wbj {
                                    background: #f1f5fb;
                                    color: #9094b0;
                                }
                            }
                        }

                        .mesTime {
                            font-size: 12px;
                            color: #9094b0;
                        }
                    }

                    &:hover,&.act {
                        .mesLsL {
                            .mesLsLT {
                                .meSp {
                                    color: #2379f7;
                                    &:after{
                                        background:#2379f7;
                                    }
                                }
                            }
                        }
                    }

                }
            }
        }


    }

    .mesCri {
     
        display: flex;
        justify-content: flex-start;
		transition: 0.3s ease;
        .mesCLB {
            flex: 1;
            width: 0;
            height: 100%;
            background: #ffffff;
            padding: 20px 4px 30px;
            display: flex;
            flex-direction: column;

            .mlbUlB {
                width: 100%;
                overflow: auto;
                flex: 1;
                padding: 0 6px;
                box-sizing: border-box;

                .mlbUl {
                    .mlbLi {
                        width: 100%;
                        display: flex;
                        justify-content: space-between;
                        align-items: center;
                        padding: 0 5px;
                        box-sizing: border-box;
                        cursor: pointer;
                       
                        .mname {
                            font-size: 15px;
                            color: #010101;
                            font-family: 'siyuanN';
                            white-space: nowrap;
                            overflow: hidden;
                            text-overflow: ellipsis;
                            margin: 0;
                        }
                        .mtime {
                            font-size: 12px;
                            color: #9094b0;
                            font-family: 'siyuanR';
                            white-space: nowrap;
                            margin-left: 6px;

                        }
                        &.isdu{
                            .mname{
                                color: #666666;
                                font-family: 'siyuanN'
                            }
                        }
                        &:hover ,&.act{
                            background: #f0f7fe;
                            color: #777777;
                            .mname{
                                color: #2379f7;
                                font-family: 'siyuanN';
                               
                            }
                        }
                    }

                }
            }



        }

        .mesCRB {
            width: 50%;
            height: 100%;
            background: #ffffff;
            padding: 20px 4px 30px;
            box-sizing: border-box;
            display: flex;
            flex-direction: column;

            .mesCRBC {
                display: flex;
                justify-content: center;
                align-items: flex-start;
                align-content: flex-start;
                flex-wrap: wrap;
                padding: 0 6px;

                .hqbj{
                    color: #2379f7;
                    font-size: 15px;
                    text-align: left;
                    width: 100%;
                    font-family: 'siyuanR';
                    line-height: 45px;
                }
                .mesPre {
                    width: 100%;

                    .mesPreImg {
                        width: 100%;
                        display: block;
                    }
                }

                .mesPreBtns {
                    width: 100%;
                    padding: 0 30px;
                    box-sizing: border-box;

                    .mesPreBtn {
                        width: 125px;
                        height: 32px;
                        background: #2379f7;
                        color: #fcfdfe;
                        opacity: 1;
                        border-radius: 5px;
                        text-align: center;
                        line-height: 32px;
                        cursor: pointer;

                        &:hover {
                            opacity: 0.7
                        }
                    }
                }
            }



        }
    }
}

.noMore {
    .noImg{
        background: url('../../assets/miscel/none.png') center center;
        background-size: 97px 97px;
        width: 97px;
        height: 97px;
        margin: 0 auto;
    }
    .noMoreP {
        font-size: 14px;
        text-align: center;
        color: #9094b0;
        width: 100%;
        text-align: center;
        line-height: 30px;
    }
    &.noHei{
        height: 100%;
        display: flex;
        justify-content: center;
        align-items: center;
        align-content: center;
        flex-wrap: wrap;
    }
}

.slideOpen .mesCLe {
    border-right: 1px solid #dbe2ee;
    background: #fcfcfd;
}

.slideOpen .mesCLeB {
    padding-right: 6px !important;
}

.slideOpen .mesCLB {
    border-right: 1px solid #dbe2ee;
}








.mesDet {
    width: 100%;
    height: 100%;
    display: flex;
    background: #ffffff;
    
    .mesHead {
        display: flex;
        justify-content: space-between;
        align-items: center;
        align-content: center;
        border-bottom: 1px solid #dbe2ee;

        .mesHLe {
            display: flex;
            justify-content: flex-start;
            align-items: center;

            .mElog {
                margin-right: 15px;

                .mElogM {
                    height: 30px;
                    display: block;
                }
            }

            .mEdes {
                    height: 30px;
                    line-height: 30px;
                    font-size: 14px;
                    font-family: 'siyuanR';
                    position: relative;
                    padding-left: 15px;
                    &::after{
                        content: '';
                        width: 2px;
                        height: 16px;
                        background: #9094b0;
                        position: absolute;
                        left: 0;
                        top: 50%;
                        transform: translate(0,-50%)
                    }
                    .mEdesT {
                        color: #9094b0;
						
                    }
                    .mEdesA{
                        color: #000;
                    }
                }

        }
        .mesCZ{
            display: flex;
            justify-content: flex-start;
            align-items: center;
            align-content: center;
            .mesCZ_it{
                width: 24px;
                height: 24px;
                margin-right: 16px;
                margin-right: 5px;
                display: flex;
                justify-content: center;
                align-items: center;
                align-content: center;
                cursor: pointer;
                &:last-child{
                    margin-right: 0;
                }
                &:hover{
                    color: #2379f7;
                }
            }
        }
        

    }


    .mesDc {
        background: #fcfcfd;
        height: 0;

        .mesDAsi {
            padding: 20px 20px;
            box-sizing: border-box;
            border-right: 1px solid #dbe2ee;
            display: flex;
            flex-direction: column;
            flex-wrap: wrap;
            .mesTh {
                width: 100%;
                display: flex;
                justify-content: space-between;
                align-items: center;
                align-content: center;
                padding-bottom: 10px;

                .mesThI {
                    font-size: 13px;
                    line-height: 28px;
                    color: #666666;
                    font-family: 'siyuanN';

                    .def {
                        color: #000000;
                    }
                }

                .mesSele {
                    width: 60px;
                    height: 28px;
                    background: #e5ebf6;
                    color: #666666;
                    font-size: 13px;
                    display: flex;
                    justify-content: center;
                    align-items: center;
                    align-content: center;
                    border-radius: 4px;

                    &.act {
                        color: #2379f7
                    }
                }
            }

            .mesListB {
                width: 100%;
                flex: 1;

                .mesDul {
                    overflow: auto;

                    .mesDli {
                        height: 50px;
                        display: flex;
                        justify-content: space-between;
                        align-items: center;
                        align-content: center;
                        padding: 0 6px 0 6px;
                        background: #ffffff;
                        border-radius: 4px;
                        cursor: pointer;

                        .dlit {
                            flex: 1;
                            width: 0;
                            display: flex;
                            justify-content: flex-start;
                            align-items: center;

                            .mdot {

                                display: block;
                                position: relative;
                                width: 10px;
                                height: 20px;
                                margin-right: 6px;

                                &::after {
                                    width: 6px;
                                    height: 6px;
                                    background: #2379f7;
                                    border-radius: 50%;
                                    content: '';
                                    position: absolute;
                                    top: 50%;
                                    left: 50%;
                                    transform: translate(-50%, -50%)
                                }
                            }

                            .mdotp {
                                flex: 1;
                                width: 0;
                                font-size: 15px;
                                font-family: 'siyuanN';
                                line-height: 20px;
                                margin: 0;
                                white-space: nowrap;
                                text-overflow: ellipsis;
                                overflow: hidden;
                            }
                        }

                        .mdtime {
                            font-size: 13px;
                            font-family: 'siyuanR';
                            color: #9094b0;
                            margin-left: 10px;
                        }

                        &:hover,
                        &.act {
                            background: #f0f7fe;

                            .dlit {
                                .mdotp {
                                    color: #2379f7;
                                }
                            }

                            .mdtime {
                                color: #777777
                            }
                        }
                    }

                }

            }

        }


        .mesMain {
            padding: 40px 40px 20px;
            display:flex;
            flex-direction:column;
            .mMt{
                padding-bottom: 14px;
                .mMt_ar{
                    font-size: 20px;
                    color: #2379f7;
                    font-family: 'siyuanM';
                    line-height: 30px;
                }
                .mMt_ot {
                    display: flex;
                    justify-content: flex-start;
                    align-items: center;
                    height: 26px;
                    .mMtI {
                        font-size: 13px;
                        color: #9094b0;
                        font-family: 'siyuanM';
                        margin-right: 10px;
                        margin-top: 6px;
                        &:last-child{
                            margin-right: 0;
                        }
                    }
                }
               
            }

            .mMC {
                width: 100%;
                border: 1px solid #dbe2ee;
                background: #ffffff;
                padding: 30px 30px;
                flex:1;
                height:0;
              
                .mMCH {
                    display: flex;
                    justify-content: flex-start;
                    align-items: center;
                    flex-wrap: wrap;
                    border-bottom: 1px solid #dbe2ee;
                    .mMCpdfs {
                        background: #f0f7fe;
                        display: flex;
                        justify-content: flex-start;
                        align-items: center;
                        padding: 0 8px;
                        line-height: 30px;
                        box-sizing: border-box;
                        margin-right: 40px;
                        margin-bottom: 15px;
                        .mMCpdf {
                            font-size: 14px;
                            color: #333333;
                            &.PDF{
                                background: url('../../assets/images/icon2.png') no-repeat left center ;
                                background-size: 16px auto;
                                padding-left: 20px;
                            }
                            &.Word{
                                background: url('../../assets/images/icon1.png') no-repeat left center ;
                                background-size: 16px auto;
                                padding-left: 20px;
                            }
                            &.Other{
                                background: url('../../assets/images/link.png') no-repeat left center ;
                                background-size: 16px auto;
                                padding-left: 20px;
                            }
                            
                        }
                        .mMCpdflx{
                            margin-left: 10px;
                            font-size: 13px;
                            color: #9094b0;
                            span{
                                margin-right: 6px
                            }
                        }
                    }
                    .mMCbts {
                        display: flex;
                        justify-content: flex-start;
                        margin-bottom: 15px;
                        .mMCdown {
                            padding: 0 20px;
                            height: 30px;
                            text-align: center;
                            line-height: 30px;
                            background: #2379f7;
                            color: #ffffff;
                            border-radius: 6px;
                            cursor: pointer;
                            white-space:nowrap ;
                            &:active{
                                opacity: 0.7
                            }
                            margin-right: 20px;
                        }
                        .mMCyx{
                            padding: 0 20px;
                            height: 30px;
                            text-align: center;
                            line-height: 30px;
                            background: #e8f1ff;
                            color: #2379f7;
                            border-radius: 6px;
                            cursor: pointer;

                            &.act{
                                background: #2379f7;
                                color: #ffffff;
                            }

                            &:active{
                                opacity: 0.7
                            }
                        }
                    } 
                }
                .mMDetai {
                    padding: 15px 0;
                    box-sizing: border-box;
                    width: 100%;
                    min-height: 200px;
                    .mMDetai {
                        .mMDetai_html{}
                    }
                 }
            }
        }
    }
}


.zuhua{
    width: 16px;
    height: 22px;
    position: absolute;
    top: 50%;
	transform: translate(0,-50%);
    right:-20px;
    background:url('../../assets/miscel/righs.png') no-repeat center left;
    background-size: 8px 11px;
    cursor: pointer;
}
.width50 {
    width: 66.66%;
}

@media screen and (max-width: 768px){
	
	.mesBox{
		width: 100%;
		height: 100%;
		border-radius: 0;
	}
	.mesMenuBtn:nth-child(1)
	{
		display: none!important;
	}
	.mesCri{
		display: none!important;
	}
	.mesCon .mesCLe{
		padding: 20px 4px 10px;
	}
	.mesCon .mesCLe .mesCLeB .mesCUl .mesCLi .mesLsL .mesLsLT .meSp{
		font-size: 14px;
	}
	.mesCon .mesCLe .mesCLeB{
		padding: 0 10px;
	}
	.mesMenu1{
	    display: flex;
	    justify-content: flex-start;
	    align-items: center;
	
	    position: absolute;
	    top: 16px;
	    right: 24px;
	    z-index:10;
	    .mesMenuBtn1{
	        width: 26px;
	        height: 26px;
	        display: flex;
	        justify-content: center;
	        align-items: center;
	        align-content: center;   
	        margin-right: 2px;
	        cursor: pointer;
	        &:last-child{
	            margin-right: 0;
	        }
	        &:hover{
	            color: #2379f7
	        }
	    }
	}
	
}


</style>